package com.banmao.CarlCamp.Day01;

import lombok.extern.slf4j.Slf4j;

/**
 * https://leetcode.cn/problems/remove-element/
 */
@Slf4j
public class LC27 {

    public int removeElement(int[] nums, int val) {
        if (nums == null || nums.length == 0) {
            return 0;
        }

        int slow = 0, fast = 0;
        while (fast <= nums.length - 1) {
            if (nums[fast] != val) {
                nums[slow++] = nums[fast++];
            } else {
                fast++;
            }
        }

        return slow;
    }

    public static void main(String[] args) {
        int[] nums = {2};
        LC27 lc27 = new LC27();
        int len = lc27.removeElement(nums, 1);
        log.info("{} -- {}", nums, len);
    }



}
